import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:marqueer/marqueer.dart';
import 'package:pornhub_app/model/mine/ann_vip_model.dart';

import '../../../assets/styles.dart';

class MarqueerVip extends StatelessWidget {
  final Widget widgets;
  final Widget? sepreate;
  final MarqueerDirection? direction;
  final double? speed;
  // models时用到
  final TextStyle? textStyle;

  const MarqueerVip(this.widgets,
      {super.key, this.sepreate, this.direction, this.speed})
      : textStyle = null;

  MarqueerVip.single(Widget widget,
      {super.key, this.sepreate, this.direction, this.speed})
      : widgets = widget,
        textStyle = null;

  MarqueerVip.deducts(
    AnnVipModel models, {
    super.key,
    this.sepreate,
    this.direction,
    this.speed,
    this.textStyle,
  }) : widgets = Text(
          models.content ?? '',
          style: textStyle ??
              TextStyle(color: Colors.white, fontSize: Styles.fontSize.s),
        );

  @override
  Widget build(BuildContext context) {
    return Marqueer.builder(
      pps: speed ?? 15,
      direction: direction ?? MarqueerDirection.rtl,
      restartAfterInteractionDuration: const Duration(seconds: 3),
      itemBuilder: (_, index) {
        return widgets;
      },
      separatorBuilder: (_, index) {
        return sepreate ?? SizedBox(width: 64.w);
      },
    );
  }
}
